package cn.edu.scau.cmi.zhangxiyang.client;

import cn.edu.scau.cmi.zhangxiyang.Factory.AbstractFactory;
import cn.edu.scau.cmi.zhangxiyang.Factory.BodyInjuryA;
import cn.edu.scau.cmi.zhangxiyang.Factory.BodyInjuryF;
import cn.edu.scau.cmi.zhangxiyang.Factory.CarDamageA;
import cn.edu.scau.cmi.zhangxiyang.Factory.CarDamageF;
import cn.edu.scau.cmi.zhangxiyang.Factory.CasualtiesA;
import cn.edu.scau.cmi.zhangxiyang.Factory.CasualtiesF;
import cn.edu.scau.cmi.zhangxiyang.Factory.FactoryMethod;
import cn.edu.scau.cmi.zhangxiyang.Factory.InsuranceProduct;
import cn.edu.scau.cmi.zhangxiyang.Factory.MultipleAccidentsA;
import cn.edu.scau.cmi.zhangxiyang.Factory.MultipleAccidentsF;
import cn.edu.scau.cmi.zhangxiyang.Factory.PICC;
import cn.edu.scau.cmi.zhangxiyang.Factory.PingAn;
import cn.edu.scau.cmi.zhangxiyang.Factory.SimpleFactory;
import java.util.*;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Scene;  
import javafx.stage.Stage;  
import javafx.scene.layout.*;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.stage.Stage;  
import javafx.scene.Scene;  

public class AbstractFactoryClient extends Application{
	
public void start(Stage primaryStage) {
		
		Stage stage = new Stage();
		BorderPane border = new BorderPane();
		GridPane gp = new GridPane();
		border.setCenter(gp);
		TextArea text = new TextArea();
		border.setBottom(text);
		
		gp.setHgap(10);
		gp.setVgap(10);
		gp.setPadding(new Insets(0, 10, 0, 10));
		
		ImageView face = new ImageView(("https://i02piccdn.sogoucdn.com/bf27c67d6f4312ba"));
		face.setFitWidth(100);
		face.setFitHeight(100);
		gp.add(face, 1, 3);
		
		Label label1 = new Label("濮撳悕锛�");
		gp.add(label1, 1, 0);
		
		Label label2 = new Label("the chainsmoker");
		gp.add(label2, 2, 0);
		
		Label label3 = new Label("瀛﹀彿锛�");
		gp.add(label3, 3, 0);
		
		Label label4 = new Label("201627010428");
		gp.add(label4, 4, 0);
		
		Label label5 = new Label("璇烽�夋嫨鍏徃锛�");
		gp.add(label5, 1, 1);
		
		ComboBox combobox = new ComboBox();
		combobox.getItems().addAll("PICC","PingAn");
		gp.add(combobox, 2, 1);
		
		Label label6 = new Label("璇烽�変繚闄╋細");
		gp.add(label6, 3, 1);
		
		ComboBox combobox1 = new ComboBox();
		combobox1.getItems().addAll("Body Injury","Car Damage","Casualties","Multiple Accidents");
		gp.add(combobox1, 4, 1);
		
		Button btn = new Button("鏄剧ず淇濋櫓淇℃伅");
		gp.add(btn, 1, 2);
		
		btn.setOnAction(e -> {  
			if(combobox.getValue() != null && combobox1.getValue() != null) {
				AbstractFactory a = null;
				if(combobox.getValue().toString().equalsIgnoreCase("PICC")) {
					a = new PICC();
				}
				else a = new PingAn();
				
				Object b = null;
				if(combobox1.getValue().toString().equalsIgnoreCase("Body Injury")) {
					b = a.useBodyInjuryProduct("");
					text.setText(((BodyInjuryA) b).use2());
				}
				else if(combobox1.getValue().toString().equalsIgnoreCase("Car Damage")) {
					b = a.useCarDamageProduct("");
					text.setText(((CarDamageA) b).use2());
				}
				else if(combobox1.getValue().toString().equalsIgnoreCase("Casualties")) {
					b = a.useCasualtiesProduct("");
					text.setText(((CasualtiesA) b).use2());
				}
				else {
					b = a.useMultipleAccidentsProduct("");
					text.setText(((MultipleAccidentsA) b).use2());
				}
			}
        });
		
	
		
		stage.setScene(new Scene(border,500,500));
		stage.setTitle("瀹為獙浜屾娊璞″伐鍘傛柟娉�");
        stage.show();
	}
	

	public static void main(String args[]) {
		launch(args);
	}

}
